package com.larsgard.gedviewer.shared.ajax;

import java.io.Serializable;

public class SearchRequest implements Serializable {

    private static final long serialVersionUID = 4316873894177478076L;

    public static enum SearchType {
	DETAIL_FOR_PERSON, LIST_OF_PERSONS
    };

    private SearchType type;
    private String[] idno;
    private int depth;
    private String firstName;
    private String familyName;
    private String sex;
    private String password;

    /**
     * @deprecated Use constructor with arguments instead.
     */
    @Deprecated
    public SearchRequest() {
    }

    public SearchRequest(SearchType type) {
	this.type = type;
    }

    public SearchRequest(SearchType type, int depth, String... idno) {
	this(type);
	this.depth = depth;
	this.idno = idno;
	switch (type) {
	case DETAIL_FOR_PERSON:
	    if (idno.length == 0) {
		throw new IllegalArgumentException(
			"Idno must be present when requesting details for a person.");
	    }
	    break;
	default:
	    // nothing

	}
    }

    public void setType(SearchType type) {
	this.type = type;
    }

    public SearchType getType() {
	return type;
    }

    public void setIdno(String[] idno) {
	this.idno = idno;
    }

    public String[] getIdno() {
	return idno;
    }

    public int getDepth() {
	return depth;
    }

    public void setSex(String sex) {
	this.sex = sex;
    }

    public String getSex() {
	return sex;
    }

    public void setFamilyName(String familyName) {
	this.familyName = familyName;
    }

    public String getFamilyName() {
	return familyName;
    }

    public void setFirstName(String firstName) {
	this.firstName = firstName;
    }

    public String getFirstName() {
	return firstName;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public String getPassword() {
	return password;
    }

}
